//
//  ZZComposeButton.swift
//  web
//
//  Created by 张卓 on 2017/2/8.
//  Copyright © 2017年 ZZ. All rights reserved.
//

import UIKit

class ZZComposeButton: UIButton {
    
    //定义一个属性共外界赋值
    var composeModel : ZZComposeModel?
    
    //因为放大按钮动画后.如果button按钮存在高亮状态,会导致效果不对
    override var isHighlighted: Bool{
        get{
            return false
        }
        set{
            
        }
    }
    

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        //设置imageView的frame
        imageView?.frame.size = CGSize(width: self.frame.size.width, height: self.frame.size.width)
        //设置 Y 轴
        imageView?.frame.origin.y = 0
        //设置 title的frame
        titleLabel?.frame.size = CGSize(width: self.frame.size.width, height: self.frame.size.height - self.frame.size.width)
//        titleLabel?.sizeToFit()
        titleLabel?.frame.origin.x = 0
//        titleLabel?.center.x = self.center.x
        titleLabel?.frame.origin.y = self.frame.size.width
    }
    
    
    //MARK: - 设置视图
    private func setupUI(){
//        backgroundColor = ZZRandomColor()
        //设置imageview 填充方式
        imageView?.contentMode = .center
        //设置 titlelabel文字的对齐方式
        titleLabel?.textAlignment = .center
        //设置 font
        titleLabel?.font = UIFont.systemFont(ofSize: ZZNORMALFONTSIZE)
        //设置颜色
        setTitleColor(UIColor.darkGray, for: UIControlState.normal)
    }

}
